<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.opensymphony.xwork2.ActionContext" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%ActionContext.getContext().getSession().get("sessionId");%>
<%ActionContext.getContext().getSession().get("jrqUid");%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <base href="<%=basePath%>">
	<title>永川软件园人才网</title>
	<meta http-equiv="X-UA-Compatible" content="IE=10;IE=9;IE=8;IE=7;IE=EDGE">
	<meta name="keywords" content="永川软件园人才网,永川软件园人才网" />
	<meta name="description" content="永川软件园人才网" />
	<link href="favicon.ico" type="image/x-icon" rel="shortcut icon">
	<link rel="stylesheet" type="text/css" href="css/style.css">
	<script src="js/jquery.1.10.1.min.js?v=1.5.5.7_1226" type="text/javascript"></script>
	<script type="text/javascript" src="js/jquery.lib.min.js?v=1.5.5.7_1226"></script>
	<script type="text/javascript" src="js/core.min.js?v=1.5.5.7_1226"></script>
	 
	<style>
	#qqLoginBtn img{
		width:50px;
		height:50px;
	}
	</style>
</head>
<body id="login_bg">
	<div class="login_wrapper">
		<div class="login_header">
        	<a href="index.jsp"><img src="images/logo_white.png" width="285" height="62" alt="永川软件园人才网招聘" /></a>
            <div id="cloud_s"><img src="images/cloud_s.png" width="81" height="52" alt="cloud" /></div>
            <div id="cloud_m"><img src="images/cloud_m.png" width="136" height="95"  alt="cloud" /></div>
        </div>

    	<input id="resubmitToken" value="" type="hidden">		
		 <div class="login_box">
        	<form id="loginForm">
				<input id="email" name="email" tabindex="1" placeholder="请输入登录邮箱地址" type="text">
			  	<input id="password" name="password" tabindex="2" placeholder="请输入密码"  type="password">
			    <span class="error" style="display:none;" id="beError"></span>
			    <label class="fl" for="remember">
				    <input checked="checked" id="remember" value="" name="autoLogin" type="checkbox"> 
				    记住我
			    </label>
			    <a href="reset.jsp" class="fr" target="_blank">忘记密码？</a>
			    <input id="submitLogin" value="登 &nbsp; &nbsp; 录" type="submit">
			</form>
			<div class="login_right">
				<div>还没有永川软件人才网帐号？</div>
				<a href="register.jsp" class="registor_now">立即注册</a>
			   
        </div>
        <div class="login_box_btm"></div>
    </div>
	<jsp:include page="jump.jsp" flush="true"/> 
<script type="text/javascript">
$(function(){
	
	/**end nancy**/
	//验证表单
	 	$("#loginForm").validate({
	 		/* onkeyup: false,
	 		focusCleanup:true,  */
	        rules: {
	    	   	email: {
	    	    	required: true,
	    	    	email: true,
	    	    	maxlength:30
	    	   	},
	    	   	password: {
	    	    	required: true,
	    	    	rangelength: [6,16]
	    	   	}
	    	},
	    	messages: {
	    	   	email: {
	    	    	required: "请输入登录邮箱地址",
	    	    	email: "请输入有效的邮箱地址，如：vip@qq.com",
	    	    	maxlength:"请输入30字以内的邮箱地址"
	    	   	},
	    	   	password: {
	    	    	required: "请输入密码",
	    	    	rangelength: "请输入6-16位密码，字母区分大小写"
	    	   	}
	    	},
	    	submitHandler:function(form){
/* 	    		if($('#remember').prop("checked")){
	      			$('#remember').val(1);
	      		}else{
	      			$('#remember').val(null);
	      		} */
	    		//$(form).find(":submit").attr("disabled", true);
	    		var uid;
            	var email = $("#email").val();
				var password = $("#password").val();
			      $.ajax({  
		               type : 'post',  
		               url : 'user_login',  
		               dataType : 'json',  
		               data :  {"username":email,"password":password},
		          	   success : function (result) {
 		          	   //alert(result.uid+"xxxx"+result.sessionId); 
			        	 
			               if(result.errcode=="40010"){
			               		$('#beError').text('').show();
			               		$("#beError").html("账号或密码错误，请重新登陆！");
			               		return;
			               }
			               if(result.errcode=="40012"){
			               		$('#beError').text('').show();
			               		$("#beError").html("账号未激 活！");
			               		return;
			               }else{
			               
			               
			               }
		              	   if(result.errcode=="0"){
		              	   		var date = new Date();
		              	   		date.setTime(date.getTime() + (3 * 24 * 60 * 60 * 1000));//一天后失效
				                $.cookie("jrqUserName", result.username, { path: '/', expires: date });
				                $.cookie("jrqUid", result.uid, { path: '/', expires: date });
		              	   		if($("#remember").is(":checked")){
		              	   			 if(result.password != null){
											$.cookie("jrqPassWord", result.password, { path: '/', expires: date });
											var url =decodeURIComponent(window.location.href);
											//取from 后面的url地址
											var location =getvl(url,"from");
											if(location!=""){
											  window.location.href=location;
											}else{
											   window.open('./index','_top');
											}
													
									  } 
								}else{
									var url =decodeURIComponent(window.location.href);
									var location =getvl(url,"from");
									if(location!=""){
									  window.location.href=location;
									}else{
									   window.open('./index','_top');
									}
								}
		              	   		//window.open('./myresume.jsp?flag='+'loginSuccess&uid='+uid,'_top');
		              	   		/*if($.cookie("sessionId") != null){
		              	   			//delayURL("登陆成功！","3","index.jsp");
		              	   			window.location.href="index.jsp";
		              	   			return;
			              	   		//window.open('./index.jsp','_top');
		              	   		}*/
			               }
		               },  
		               error : function () {  
		               		//delayURL("接口异常!","3","");
               				return;
		               }  
		           });               
	        }  
		});
});
var url = "";
//var url = "https://api.weibo.com/oauth2/authorize?client_id=931633416&redirect_uri=http://www.bangv.com&response_type=code";
$(".icon_wb").click(function(){
	window.open(url,"_blank");
	 /*$.ajax({  
         type : 'post',  
         url : 'weibo-OAuthCode',  
         dataType : 'json',  
         data :  {},
    	 success : function (result) {
    		 if(result.errcode==0){
	    		 window.open(result.url,"_blank");
    		 }
         }
     });*/
});
function getvl(url,name) {
var reg = new RegExp("(^|\\?|&)"+ name +"=([^&]*)(\\s|&|$)", "i");
if (reg.test(url)) return unescape(RegExp.$2.replace(/\+/g, " "));
return "";
};
</script>
</body>
</html>